extends CharacterBody2D
class_name  Bullet02

@export var speed = 100
var dir:Vector2

func setDir(value:Vector2):
	dir = value
	

func setSpeed(spd):
	speed = spd
	
	
func setPos(pos):
	position = pos


func _physics_process(delta):
	velocity = dir * speed
	move_and_slide()
	
	checkDestroy()
	

func checkDestroy():
	if position.x < -10 or position.x > 190 or position.y < -10 or position.y > 330:
		queue_free() 


func _on_hit_area_area_entered(area:Area2D):
	queue_free()
	if area.name == "PlayerHitArea":
		Global.signalPlayerHit.emit()
